package com.example.friend.controller;


import com.example.core.constants.HttpConstants;
import com.example.core.controller.BaseController;
import com.example.core.entity.PageDataInfo;
import com.example.core.result.Res;
import com.example.friend.aspect.CheckUserStatus;
import com.example.friend.entity.DTO.ExamQueryDTO;
import com.example.friend.entity.DTO.ExamSignUpDTO;
import com.example.friend.entity.VO.ExamVO;
import com.example.friend.service.IUserExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CheckUserStatus
@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {
    @Autowired
    private IUserExamService userExamService;


    @PostMapping("/signUp")
    public Res<Void> signUp(@RequestHeader(HttpConstants.AUTHENTICATION) String token,
                            @RequestBody ExamSignUpDTO examSignUpDTO) {
        return toR(userExamService.signUp(token, examSignUpDTO.getExamId()));
    }

    @GetMapping("/list")
    public PageDataInfo<ExamVO> list(ExamQueryDTO examQueryDTO) {
        return userExamService.list(examQueryDTO);
    }
}
